#!/bin/bash
#%depends: tuda_partition_disks tuda_mount tuda_sync tuda_finalize
#%stage: setup
#%provides: tuda
#Author: Geert Geurts, geert.geurts@hrz.tu-darmstadt.de
mkdir -p $tmp_mnt/usr/bin 
mkdir -p $tmp_mnt/usr/sbin 
mkdir -p $tmp_mnt/lib
mkdir -p $tmp_mnt/etc/ssh
mkdir -p $tmp_mnt/var/run/sshd
mkdir -p $tmp_mnt/var/lib/empty
mkdir -p $tmp_mnt/roothome/.ssh
chmod 750 $tmp_mnt/roothome/.ssh
echo -e "#!/bin/bash\necho 1>/tmp/continue_boot">$tmp_mnt/roothome/.bash_logout
echo "It might take up to 30 seconds after logout before initrd actually continues...">>$tmp_mnt/etc/motd
ssh-keygen -t rsa -N '' -f $tmp_mnt/etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -N '' -f $tmp_mnt/etc/ssh/ssh_host_dsa_key
cp /lib/tuda-mkinitrd/lib/ssh_config $tmp_mnt/etc/ssh/
cp /lib/tuda-mkinitrd/lib/sshd_config $tmp_mnt/etc/ssh/
echo "sshd:x:105:65534::/var/run/sshd:/sbin/nologin">>$tmp_mnt/etc/passwd
sed -i '/root/d' $tmp_mnt/etc/passwd
echo "root:x:0:0:root:/roothome:/bin/bash">>$tmp_mnt/etc/passwd
cp /lib/tuda-mkinitrd/lib/known_hosts $tmp_mnt/etc/ssh/
ID=$(cat /root/.ssh/id_rsa.pub)
echo $ID>>$tmp_mnt/roothome/.ssh/authorized_keys
chmod 600 $tmp_mnt/roothome/.ssh/authorized_keys
cp /lib/tuda-mkinitrd/lib/tuda-lib.sh $tmp_mnt/lib/
cp /lib/tuda-mkinitrd/lib/tuda-id_rsa* $tmp_mnt/lib/
cp /lib/tuda-mkinitrd/lib/rsync.awk $tmp_mnt/lib/

